<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="DataTables/datatables.min.css"/>
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>胆流转完整度分析</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span>
	统计分析
	<span class="c-gray en">&gt;</span>
	胆流转完整度分析
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container" id="app">
	<div class="text-c">
		<form id="queryForm">
			<span> 日期范围：
			<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'endTime\')||\'%y-%M-%d\'}' })" id="startTime" name="startTime" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'startTime\')}',maxDate:'%y-%M-%d' })" id="endTime" name="endTime" class="input-text Wdate" style="width:120px;">
			</span>
			分公司: <span class="select-box inline">
				<select class="select" id="companyid" name="companyid" onchange="queryOffice(this.value)"></select>
			</span>
			票务室: <span class="select-box inline">
				<select class="select" id="officeid" name="officeid">
					<option value>请选择票务室</option>
				</select>
			</span>
			<input type="text" name="c_id" id="query" placeholder="请输入胆号" style="width:250px" class="input-text" v-model="msg">
			<button class="btn btn-success" type="button" v-on:click="query()"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
		</form>
	</div>
	<div class="mt-20">
		<table id="list" class="table table-border table-bordered table-hover table-bg table-sort">
		</table>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="DataTables/datatables.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript" src="js/vue.js" charset="utf-8"></script>
<script type="text/javascript">

function queryOffice(companyid){
	$.ajax({
		url: ipAddress + 'base/office/getList',
		// url: 'http://localhost:8080/base/office/getList',
		data: {
			"company.companyid": companyid,
			order: "id"
		},
		beforeSend: function (request) {
			request.setRequestHeader("Authorization", "Bearer " + getToken());
		},
		method:'GET',
		success:function (data,status,request) {
			console.log(data);
			$("#officeid").empty();
			$("#officeid").append("<option value>请选择票务室</option>");
			for(var i = 0; i < data.length; i ++){
				$("#officeid").append("<option value='" + data[i].id + "'>" + data[i].officename + "</option>");
			}
		},
		error:function (request, msg, obj) {
			var respTxtObj = JSON.parse(request.responseText);
			console.log(respTxtObj);
			console.log(respTxtObj.error);
			console.log(respTxtObj.error_description);
		}
	});
}

$.ajax({
	url: ipAddress + 'base/company/getList',
	data: {
		order: "ordercode"
	},
	beforeSend: function (request) {
		request.setRequestHeader("Authorization", "Bearer " + getToken());
	},
	method:'GET',
	success:function (data,status,request) {
		console.log(data);
		$("#companyid").append("<option value>请选择分公司</option>");
		for(var i = 0; i < data.length; i ++){
			$("#companyid").append("<option value='" + data[i].companyid + "'>" + data[i].companyname + "</option>");
		}
	},
	error:function (request, msg, obj) {
		var respTxtObj = JSON.parse(request.responseText);
		console.log(respTxtObj);
		console.log(respTxtObj.error);
		console.log(respTxtObj.error_description);
	}
});
</script>

<script type="text/javascript">
	var vm = new Vue({
		el : "#app",
		data : {
			msg : "",
			isAdmin : true
		},
		//在实例初始化之后，数据观测 (data observer) 和 event/watcher 事件配置之前被调用。
		beforeCreate:function(){
			console.log('beforeCreate');
		},
		/* 在实例创建完成后被立即调用。
		在这一步，实例已完成以下的配置：数据观测 (data observer)，属性和方法的运算，watch/event 事件回调。
		然而，挂载阶段还没开始，$el 属性目前不可见。 */
		created	:function(){
			console.log('created');
		},
		//在挂载开始之前被调用：相关的渲染函数首次被调用
		beforeMount : function(){
			console.log('beforeMount');
	
		},
		//el 被新创建的 vm.$el 替换, 挂在成功	
		mounted : function(){
			console.log('mounted');
		
		},
		//数据更新时调用
		beforeUpdate : function(){
			console.log('beforeUpdate');
				
		},
		//组件 DOM 已经更新, 组件更新完毕 
		updated : function(){
			console.log('updated');
				
		},
		methods: {
			query: function(){
				table.draw();
			}
		}
	});
	
	$('#startTime').val(today());
	$('#endTime').val(today());
	
	var table = $('#list').DataTable({
		language: {
			url: 'static/h-ui.admin/js/de_DE.txt'
		},
		//stateSave: true,
		"lengthMenu":[10, 50, 100],
		"pageLength": 100,
		searching: false,
		processing: true,
		serverSide: true,
		order: [[1, 'asc']],
		ajax: {
			 url: ipAddress + 'demo/cashboxRecordReport/getAnalysisTablePage',
			//url: 'http://localhost:8000/vehicle/getTablePage',
			type: 'GET',
			data: function ( data ) {
				var param = {};
				var userInfo = getUserInfo();
				var page = data.start == 0 ? 0 : data.start / data.length;
				var size = data.length;
				var order = data.columns[data.order[0].column].data + " " + data.order[0].dir;
				param.draw = data.draw;
				param.page = page;
				param.size = size;
				param.like = '%c_id%';
				param.order = order;
				var formData = $("#queryForm").serializeArray();//把form里面的数据序列化成数组
				formData.forEach(function (e) {
					console.log(e.value == '');
					// if(e.value){
						param[e.name] = e.value;
					// }
				});
				if(hasRole('COMPANY')){
					vm.isAdmin = false;
				}
				return param;
			}
		},
		columns: [
			{title: '分公司', name: 'companyname', data: 'companyname', defaultContent: '无'},
			{title: '票务室', name: 'officename', data: 'officename', defaultContent: '无'},
			{title: '胆号', name: 'c_id', data: 'c_id', defaultContent: '无'},
			{title: '是否异常', name: 'isexc', data: 'isexc', defaultContent: '无',
				render: function(data, type, full, meta) {
					if (data == 0) {
						return '正常';
					} else {
						return '异常';
					}
				}
			},
			{title: '流转开始时间', name: 'firsttime', data: 'firsttime', defaultContent: '无'},
			{title: '流转结束时间', name: 'endtime', data: 'endtime', defaultContent: '无'},
			{title: '耗时天数', name: 'diffday', data: 'diffday', defaultContent: '0'},
			{title: '异常上报次数', name: 'exctimes', data: 'exctimes', defaultContent: '0'},
			{title: '流转图表', name: 'cbr_circletimes', data: 'cbr_circletimes', defaultContent: '无',
				render: function(data, type, full, meta) {
					console.log(full);
					if(full.c_id.indexOf("C") != -1){
						name = "钱胆("+full.c_id+")流转环节轨迹";
						return  '<a style="text-decoration:underline;" onclick="report_cashbox_view(\''+name+'\',\'report-cashbox-view.html?id='+full.c_id+'&step='+full.cbr_circletimes+'&stepname='+full.step+'\',\'\',\'800\',\'500\')" href="javascript:;">'+data+'</a>';
					}else{
						name = "款包("+full.c_id+")流转环节轨迹";
						return  '<a style="text-decoration:underline;" onclick="report_cashbox_view(\''+name+'\',\'report-cashbox-view-R.html?id='+full.c_id+'&step='+full.cbr_circletimes+'&stepname='+full.step+'\',\'\',\'800\',\'500\')" href="javascript:;">'+data+'</a>';
					}
				}
			}
		],
		columnDefs: [
			{"orderable":false,"targets":[8]}
		]
	});
	
function report_cashbox_view(title, url, id, w, h) {
	layer_show_cr(title, url, w, h);
} 
function layer_show_cr(title,url,w,h){
	if (title == null || title == '') {
		title=false;
	};
	if (w == null || w == '') {
		w=800;
	};
	if (h == null || h == '') {
		h=($(window).height() - 50);
	};
	layer.open({
		type: 2,
		area: [w+'px', h +'px'],
		fix: false, //不固定
		maxmin: true,
		shade:0.4,
		title: title,
		content: url,
		end:function(){
			//location.reload();
		}
	});
}
</script>
</body>
</html>